package db

import (
	"ruikc.com/server/models"
	xb "xorm.io/builder"
)

func ClassifyMap() map[uint]string {
	datas := []models.Classify{}
	FindDatasAsc(&datas, xb.And(xb.Gt{"id": 0}))
	result := make(map[uint]string)
	for _, v := range datas {
		result[uint(v.Id)] = v.Title
	}
	return result
}

func InstructorMap() map[int]models.Instructor {
	datas := []models.Instructor{}
	FindDatasAsc(&datas, xb.Gt{"id": 0})
	result := make(map[int]models.Instructor)
	for _, v := range datas {
		result[v.Id] = v
	}
	return result
}

func DeptMap() map[int]models.Dept {
	datas := []models.Dept{}
	FindDatasAsc(&datas, xb.Gt{"id": 0})
	result := make(map[int]models.Dept)
	for _, v := range datas {
		result[v.Id] = v
	}
	return result
}

func CategoryMap() map[int]models.Category {
	datas := []models.Category{}
	FindDatasAsc(&datas, xb.Gt{"id": 0})
	result := make(map[int]models.Category)
	for _, v := range datas {
		result[v.Id] = v
	}
	return result
}
